package com.hrt;

import com.hrt.mapper.EmpMapper;
import com.hrt.pojo.Emp;
import com.hrt.util.SqlSessionUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * @Auther: hrt
 * @Date: 2021/10/14
 * 使用代理模式查询
 */
public class ManyParemeterTest {
        public static void main(String[] args) {
            SqlSession sqlSession = SqlSessionUtil.getSqlSession();
            EmpMapper mapper = sqlSession.getMapper(EmpMapper.class);
            List<Emp> emps = mapper.findAll();
            for(Emp emp:emps) {
                System.out.println(emp);
            }
            // 1单个基本数据类型作为方法参数
            Emp emp = mapper.findByEmpno(7902);
            System.out.println(emp);
            // 2多个基本数据类型作为方法参数
            List<Emp> emps2 = mapper.findByDeptnoAndSal(10, 1500);
            for(Emp em:emps2) {
                System.out.println(em);
            }
            // 3单个引用类型作为方法参数
            Emp condition=new Emp();
            condition.setDeptno(10);
            condition.setSal(1500.0);
            List<Emp> emps3 = mapper.findByDeptnoAndSal3(condition);
            for(Emp em:emps3) {
                System.out.println(em);
            }
            // 4多个引用类型作为方法参数
            Emp condition1=new Emp();
            condition1.setDeptno(10);
            Emp condition2=new Emp();
            condition2.setSal(1500.0);
            List<Emp> emps4 = mapper.findByDeptnoAndSal4(condition1,condition2);
            for(Emp em:emps4) {
                System.out.println(em);
            }
            sqlSession.close();
        }
}
